<?php
function fengchao($qry) {
$ch = curl_init('http://fengchao.baidu.com/dwr/call/plaincall/twr.tcg.dwr');
$header = array(
'Host: fengchao.baidu.com',
'User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language: zh-cn,zh;q=0.5',
'Accept-Encoding: gzip,deflate',
'Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7',
'Keep-Alive: 115',
'Connection: keep-alive',
'Content-Type: text/plain; charset=UTF-8',
'Referer: http://fengchao.baidu.com/fc-mc/spread/initKeywordRecommend.do?userid=2109950&castk=c9e75ej744ab1daddd201',
'Content-Length: 509',
'Cookie: BAIDUID=50F547BFED2775CCAD29131BA27C9EC2:FG=1; BD_UTK_DVT=1; __utma=147196964.1579635213.1277796284.1277796284.1277890242.2; __utmz=147196964.1277890242.2.2.utmcsr=baidu.hexun.com|utmccn=(referral)|utmcmd=referral|utmcct=/stock/q.php; USERID=1b1218bd17387ee6aa6b; SIGNIN_UC=70a2711cf1d3d9b1a82d2f87d633bd8a00423185922; SFSSID=760bbb699b46f04c321c30af382a3523; __cas__rn__=42318592; __cas__id__3=2109950; __cas__st__3=2a90b44bd225698d7d085b71d09ee5ac66aa54de662332ffafe8ee7deb346f6a270961206b8d963c4aebae4a; JSESSIONID=1364DE25E61F97ACC76BA6876217C61B.worker; SAMPLING_COOKIE=e19a0f20dda4b2109950; userclicktimestamp2109950=1292307701562',
'Pragma: no-cache',
'Cache-Control: no-cache',
);
$post = "callCount=1\npage=/fc-mc/spread/initKeywordRecommend.do?userid=2109950&castk=c9e75ej744ab1daddd201\nhttpSessionId=CCFB0D7DEE563AF54C86D77A2E217118.worker\nscriptSessionId=E5930CC6055F50622E5843F0A9431126145\nc0-scriptName=twr\nc0-methodName=tcg\nc0-id=0\nc0-param0=number:2109950\nc0-param1=number:-1\nc0-param2=string:$qry\nc0-param3=number:2\nc0-param4=string:0\nc0-param5=string:\nc0-param6=number:1\nc0-param7=number:0\nc0-param8=number:0\nc0-param9=number:0\nc0-param10=number:0\nbatchId=6\n";
curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER=>1,
    CURLOPT_POST=>1,
    CURLOPT_HTTPHEADER=>$header,
    CURLOPT_POSTFIELDS=>$post
));
$data = curl_exec($ch); 
return $data;
}

if (isset($_GET['q'])) {
    $q = trim($_GET['q']);
    echo fengchao(urlencode($q));
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Baidu Fengchao keyword tools</title>
</head>
<body>
<form action="" method="get">
<input type="text" name="q" value="" /> <input type="submit" value="GO" />
</form>
</body>
</html>
